package com.alili_tv.system.service.impl;

import com.alili_tv.system.entity.CollectFolder;
import com.alili_tv.system.entity.Video;
import com.alili_tv.system.mapper.CollectFolderMapper;
import com.alili_tv.system.service.CollectFolderService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Map;

@Service
public class CollectFolderServiceImpl extends ServiceImpl<CollectFolderMapper, CollectFolder> implements CollectFolderService {

    @Resource
    private CollectFolderMapper collectFolderMapper;
    @Override
    public boolean isCollect(long videoId, long userId) {
        LambdaQueryWrapper<CollectFolder> queryWrapper = new LambdaQueryWrapper<CollectFolder>()
                .eq(CollectFolder::getCreateUser, userId)
                .eq(CollectFolder::getVideoId, videoId);
        long count = this.count(queryWrapper);
        return count > 0;
    }

    @Override
    public long countByVideoId(long videoId) {
        LambdaQueryWrapper<CollectFolder> queryWrapper = new LambdaQueryWrapper<CollectFolder>()
                .eq(CollectFolder::getVideoId, videoId);
        return this.count(queryWrapper);
    }


}
